package main.java.service.impl;


import dao.SupplierMapper;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pojo.Supplier;
import service.SupplierService;

import java.util.List;
import java.util.function.Supplier;

@Transactional
@Service("supplierService")
public class SupplierServiceImpl  implements SupplierService {
    @Autowired
    private SupplierMapper supplierMapper;
    @Override
    public List<Supplier> getlist(Supplier supplier) {
        return supplierMapper.selectgetList(supplier);
    }
    @Override
    public boolean add(Supplier supplier){
        boolean result =false;
        try {
            if (supplierMapper.add(supplier)==1){
                result=true;
            }
        }catch (RuntimeException e){
            e.printStackTrace();;
            throw e;
        }
        return result;
    }

    @Override
    public boolean delete(Supplier supplier) {
        boolean result = false;
        try {
            if (supplierMapper.delete(supplier)==1){
                result=true;
            }
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
        return result;
    }

    @Override
    public boolean update(Supplier supplier) {
        boolean result = false;
        try {
            if (supplierMapper.update(supplier)==1){
                result=true;
            }
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
        return result;
    }
}